﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>套餐设置-新增套餐</title> <#include "../common/Resources.ftl"/>
<script type="text/javascript"
	src="${base}/scripts/plugin/easy_validator.pack.js"></script>
</head>
<body>
	<div id="mainWraper" class="clearfix">
		<div class="edit-box borker-edit-box">
			<div class="edit-box-hd">
				<div class="tool">
					<div class="fl">
						<a class="mini-button " href="${ctx}/comboSetup/manager"><span
							class="mini-button-text">返回</span> </a>
					</div>
					<div class="fr">
						<div class="breadCrumb">您的位置：<a href="${ctx}/comboSetup/manager">套餐设置</a> &gt; <span class="current">新增套餐</span></div>
					</div>
				</div>
			</div>
			<div class="edit-box-bd">
				<div class="form-box">
					<table width="" border="0" cellspacing="0" cellpadding="0"
						class="form-table form-table-towcols">
						<tr>
							<th align="right" scope="col">名称：</th>
							<td scope="col"><input type="text" name="name" id="name"
								class="input-text" reg='Required' tip="请输入名称" /></td>
						</tr>
						<tr>
							<th align="right">租房数量：</th>
							<td><label> <input type="text" name="rentingCount"
									id="rentingCount" class="input-text" reg='number' tip="请输入数字" />
							</label>
							</td>
						</tr>
						<tr>
							<th align="right">租房刷新次数：</th>
							<td><input type="text" name="rentRefurbish"
								id="rentRefurbish" class="input-text" reg='number' tip="请输入数字" />
								次/天</td>
						</tr>
						<tr>
							<th align="right">售房数量：</th>
							<td><input type="text" name="sellHouse" id="sellHouse"
								class="input-text IDcard" reg='number' tip="请输入数字" />
							</td>
						</tr>
						<tr>
							<th align="right">售房刷新次数：</th>
							<td><input type="text" name="sellRefurbish"
								id="sellRefurbish" class="input-text blongStore" reg='number'
								tip="请输入数字" /> 次/天</td>
						</tr>

						<tr>
							<th align="right">计量时间：</th>
							<td><input type="text" name="measure" id="measure"
								class="input-text IDcard" reg='number' tip="请输入数字" /> 个月</td>
						</tr>
						<tr>
							<th align="right">价格：</th>
							<td><input type="text" name="price" id="price"
								class="input-text IDcard" reg='number' tip="请输入数字" /> 元</td>
						</tr>
						<tr>
							<th align="right">城市：</th>
							<td><input type="text" name="areaName" id="areaName"
								class="input-text IDcard" reg='Required' tip="请选择城市"
								readonly="readonly" onfocus="$('#areadiv').show();" />
								<div style="position: relative; display: none;" id="areadiv">
									<div class="selectCity-pop" style="">
										<div class="city-hd">
											<ul class="clearFix">
												<li class="current"><a href="javascript:void(0)">热门城市</a>
												</li>

											</ul>
										</div>
										<div class="city-bd">
											<ul class="clearfix">
												<#if areaList??> <#list areaList as area>
												<li class=""><label> <input name="area"
														id="area" onclick="onclickArea();" type="checkbox"
														value="${area.name}" />${area.name}</label>
												</li> </#list> </#if>
											</ul>
										</div>
										<div class="city-ft">
											<a class="mini-button "
												href="javascript:void(0)" onclick="setCity()"><span
												class="mini-button-text" id="setCityDone">完成</span>
											</a>
										</div>
									</div>
								</div></td>
						</tr>
						<tr>
							<th align="right">&nbsp;</th>
							<td>
								<div class="form-button">
									<a class="mini-button importantBtn"
										href="javascript:toSubmit();"><span
										class="mini-button-text">保存</span>
									</a>
								</div></td>

						</tr>
					</table>
					</form>
				</div>
			</div>

		</div>
	</div>
	<!--右边结束 -->
</body>
<script>
	function onclickArea() {
		var areaName = "";
		var area = $(":checkbox:checked").each(function() {
			if (areaName != "") {
				areaName = areaName + "," + $(this).val();
			} else {
				areaName = $(this).val();
			}
		});
		$("#areaName").val(areaName)
	}

	function toSubmit() {
		if(validateForm($("#mainWraper"))){
		$.ajax({
			url : ctx + '/comboSetup/save',
			dataType : 'json',
			type : 'post',
			data : {
				'name' : $("#name").val(),
				'areaName' : $("#areaName").val(),
				'price' : $("#price").val(),
				'measure' : $("#measure").val(),
				'sellRefurbish' : $("#sellRefurbish").val(),
				'sellHouse' : $("#sellHouse").val(),
				'rentRefurbish' : $("#rentRefurbish").val(),
				'rentingCount' : $("#rentingCount").val()
			},
			success : function(data) {
				if (data.message == "1") {					
					art.dialog.optTips('保存成功',3,"success");
					location.href= ctx + '/comboSetup/manager';
				} else {
					art.dialog.optTips('保存失败',3,"failure");
				}
			}
		});
		}
	}
	function setCity(){
		$('#areadiv').hide();
		if(!$("#areaName").val()){
			change_error_style($("#areaName"),"add")
		}else{
			change_error_style($("#areaName"),"remove")
		}
	}
</script>
</html>
